package com.fand.platform.configuration.validator;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.fand.platform.configuration.dto.DictionaryTyDto;

/**
 * 字典类型
 * 
 * @author yaoHT
 */
@Component(DictionaryTyByMoveValidator.BEAN_ID)
public class DictionaryTyByMoveValidator implements Validator {
	public static final String BEAN_ID = "com.fand.platform.configuration.validator.DictionaryTyByMoveValidator";

	@Override
	public boolean supports(Class<?> clazz) {
		return DictionaryTyDto.class.equals(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		final DictionaryTyDto dictionaryTy = (DictionaryTyDto) target;

		if (StringUtils.isBlank(dictionaryTy.getId())) {
			errors.reject("id_required", "标识不能为空");
		}
	}
}
